<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="body">										
			<h:form onkeypress="if (event.keyCode == 13) return false;">
							
				<rich:notifyMessages stayTime="2000" nonblocking="true" />
				
				<rich:accordion switchType="client">
					<rich:accordionItem header="#{msg.config}">
						<table>
							<tr>
								<td>
									<h:selectOneMenu id="search_building_name" styleClass="selectClass"									
										value="#{floorPlanMaintainBean.selectedBuildingId}" 
										required="true" requiredMessage="#{msg.building_name}-#{msg.required_field}"
										valueChangeListener="#{floorPlanMaintainBean.buildingValueChanged}">
										
										<f:selectItems value="#{floorPlanMaintainBean.buildingOptions}" />
										<a4j:ajax event="valueChange" render="search_floor_name" />
										
									</h:selectOneMenu> 	
								</td>
									
								<td>	
									<h:selectOneMenu id="search_floor_name" styleClass="selectClass"
										value="#{floorPlanMaintainBean.selectedFloorId}" 
										required="true" requiredMessage="#{msg.floor_name}-#{msg.required_field}" >										
										<f:selectItems value="#{floorPlanMaintainBean.floorOptions}" />
									</h:selectOneMenu> 	
								</td>
								
								<td>	
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;"
										value="#{msg.select}" action="#{floorPlanMaintainBean.select}" render="@form" />
								</td>
							</tr>
							<tr>
								<td colspan="3">
									<rich:fileUpload fileUploadListener="#{floorPlanMaintainBean.uploadListener}" id="upload" acceptedTypes="jpg, gif, png, bmp"
                						ontyperejected="alert('Only JPG, GIF, PNG and BMP files are accepted');" maxFilesQuantity="1">
                						<a4j:ajax event="uploadcomplete" execute="@none" render="@form" />
            						</rich:fileUpload>
								</td>
							</tr>
							<a4j:repeat value="#{floorPlanMaintainBean.machines}" var="machine" rows="20" id="repeat">
								<tr>
									<td>
										<h:panelGrid columns="2">
											<h:outputText value="#{machine.room.roomName}" styleClass="outputText" style="font-size: 16px;" />
											<h:outputText value="#{machine.machineName}" styleClass="outputText" style="font-size: 16px;" />
											<h:outputText value="#{machine.posX}" styleClass="inputText" style="font-size: 16px;" />
											<h:outputText value="#{machine.posY}" styleClass="inputText" style="font-size: 16px;" />
											<h:outputText value="#{machine.width}" styleClass="inputText" style="font-size: 16px;" />
											<h:outputText value="#{machine.height}" styleClass="inputText" style="font-size: 16px;" />
										</h:panelGrid>
									</td>
								</tr>
							</a4j:repeat>
							
						</table>
					</rich:accordionItem>
					<rich:accordionItem header="#{msg.floorplan}">
						<h:panelGroup id="plan" layout="block">
							<a4j:mediaOutput element="img" cacheable="false" session="false"
					                 createContent="#{floorPlanMaintainBean.paint}" mimeType="image/jpeg" />
						</h:panelGroup>
					
					</rich:accordionItem>
				</rich:accordion>			
			</h:form>		
							
			    
		</ui:define>
	</ui:composition>
</body>
</html>
